#ifndef QHTMLPARSER_H
#define QHTMLPARSER_H


#include <QtCore/QString>
#include <QtCore/QDate>


/* Forwarding declaration */
class QZodiac;


/**
 * This class parses the html page and returns the formatted astrology result
 * It can only read from local file currently.
 * 
 * @author gonwan(gonwan@gmail.com)
 * @version 1.0
 */
class QHtmlParser
{
public:
    /**
     * Constructor
     * It reads data from file into memory for parsing
     * @param strPath The file path
     */
    QHtmlParser(/*in*/ const QString &strPath);
    /**
     * This function retrieves the final formatted data
     * @param dtDate The date of current day
     * @param zodiac The zodiac of current day
     * @return The final formatted data
     */
    QString getAllFormatted(/*in*/ const QDate &dtDate, /*in*/ const QZodiac &zodiac) const;
    /**
     * This function retrieves the star count by a given key
     * @param strKey The key, may be love, work etc.
     * @return The star count
     */
    int getStar(/*in*/ const QString &strKey) const;
    /**
     * This function retrieves the star count by a given key, formatted
     * @param strKey The key, may be love, work etc.
     * @return The star count, formatted
     */
    QString getStarFormatted(/*in*/ const QString &strKey) const;
    /**
     * This function retrieves the content by a given key
     * @param strKey The key, may be luck color, luck number etc.
     * @return The content
     */
    QString getContent(/*in*/ const QString &strKey) const;
    /**
     * This function retrieves the content by a given key, formatted
     * @param strKey The key, may be luck color, luck number etc.
     * @return The content, formatted
     */
    QString getContentFormatted(/*in*/ const QString &strKey) const;
    /**
     * This function retrieves the major content
     * @return The major content
     */
    QString getMajorContent() const;
    /**
     * This function retrieves the major content, formatted
     * @return The major content, formatted
     */
    QString getMajorContentFormatted() const;

private:
    /**
     * This function initialize the class
     * It reads data from file into memory
     * @return true if success
     */
    bool init();
    /** The file path */
    QString m_strPath;
    /** The string buffer contains star and content infos */
    QString m_strStars;
    /** The string buffer contains major content infos */
    QString m_strContents;

};


#endif
